import Vue from "vue";
import VueRouter from "vue-router";
import Login from "@/views/Login/login.vue";
import Home from "@/views/Home/home.vue";
import Signin from "@/views/signin/signin.vue";
import Live from "@/views/live/index/index.vue"
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    component: Login,
    children: [
      {
        path: "/login",
        name: "login",
        component: () => import("@/components/login/login.vue"),
        rule: ['3', '4']
      },
      {
        path: "/authentication",
        name: "authentication",
        component: () => import("@/components/login/authentication.vue"),
      },
    ],
  },
 
  {
    path: "/home",
    redirect: "/quickConsultation",
    component: Home,
    meta: { rule: ['3', '4'] },
    children: [
      {
        path: "/404",
        name: "404",
        component: () => import("@/views/404/404.vue"),
        meta: { rule: ['3', '4'] }
      },
      {
        path: "/courseManagement",
        name: "courseManagement", //课程管理
        component: () => import("@/views/courseManagement/index/index.vue"),
        meta: { rule: ['3'] }
      },
      {
        path: "/courseList/:id",
        name: "courseList", //课程管理-课程信息
        component: () => import("@/views/courseManagement/courseList/courseList.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/cousreDetail",
        name: "cousreDetail", //课程管理-课程播放
        component: () => import("@/views/courseManagement/cousreDetail/cousreDetail.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/handleCourse",
        name: "handleCourse", //课程管理-编辑 设计
        component: () =>
          import("@/views/courseManagement/course/handleCourse.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/signin",
        name: "signin", //签到管理   护士端  后续分离路由
        component: () => import("@/views/signin/signin.vue"), meta: { rule: ['4'] }
      },
      {
        path: "/quickConsultation",
        name: "quickConsultation", //快速问诊
        component: () =>
          import("@/views/quickConsultation/quickConsultation/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/order",
        name: "order", //快速会诊 -预约信息
        component: () => import("@/views/order/order.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/completed",
        name: "completed", //快速会诊-已完成
        component: () =>
          import("@/views/quickConsultation/completed/completed.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/enterConsultation",
        name: "enterConsultation", //快速会诊-进入会诊
        component: () =>
          import(
            "@/views/quickConsultation/enterConsultation/enterConsultation.vue"
          ), meta: { rule: ['3'] }
      },
      {
        path: "/evaluate",
        name: "evaluate", //我的评价
        component: () => import("@/views/evaluate/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/revenueManagement",
        name: "revenueManagement", //收益管理
        component: () => import("@/views/revenueManagement/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/online",
        name: "online", //在线问诊
        component: () => import("@/views/online/index/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/chat",
        name: "chat", //在线问诊
        component: () => import("@/views/online/detail/chat.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/prescription",
        name: "prescription", //处方管理
        component: () => import("@/views/prescription/index/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/editPrescription",
        name: "editPrescription", //处方管理-编辑处方
        component: () =>
          import("@/views/prescription/editPrescription/editPrescription.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/encyclopedia",
        name: "encyclopedia", //健康科普
        component: () => import("@/views/encyclopedia/index/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/addPopularization",
        name: "addPopularization", //健康科普-添加
        component: () =>
          import("@/views/encyclopedia/add/addPopularization.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/popularizationDetail",
        name: "popularizationDetail", //健康科普-详情
        component: () =>
          import("@/views/encyclopedia/detail/popularizationDetail.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/personalCenter",
        name: "personalCenter", //个人中心
        component: () => import("@/views/personalCenter/index/index.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/setuserInfo",
        name: "setuserInfo", //个人中心-修改个人信息
        component: () =>
          import("@/views/personalCenter/setuserInfo/setuserInfo.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/setting",
        name: "setting", //个人中心-账号设置
        component: () => import("@/views/personalCenter/setting/setting.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/setNumInfo/:id",
        name: "setNumInfo", //个人中心-密码及手机号修改
        component: () =>
          import("@/views/personalCenter/setNumInfo/setNumInfo.vue"), meta: { rule: ['3'] }
      },
      {
        path: "/live",
        name: "live", //直播
        redirect:"/live/start",
        component:Live,
        meta: { rule: ['3'] },
        children:[
          {
            path: "/live/record",
            name: "liveRecord", //直播记录
            component:()=>import("@/views/live/record/record.vue"), meta: { rule: ['3'] }
          },
          {
            path: "/live/start",
            name: "liveIndex", //开始直播
            component:()=>import("@/views/live/startLive/startLive.vue"), meta: { rule: ['3'] }
          },
          {
            path: "/live/emit/:data",
            name: "liveEmit", //编辑
            component:()=>import("@/views/live/emit/emit.vue"), meta: { rule: ['3'] }
          },
          {
            path: "/live/add",
            name: "liveAdd", //新增
            component:()=>import("@/views/live/add/add.vue"), meta: { rule: ['3'] }
          }
        ]
      },
    ],
  },
];
const originalPush = VueRouter.prototype.push;
//冗余导航配置
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
const router = new VueRouter({
  mode: "history",
  routes,
});

export default router;
